import React, { Component } from 'react'

import Son1 from './Son1'
import Son2 from './Son2'
export default class Father extends Component {
    state = {
        money1: 10000,
        money2: 20000,
        girls1: ['翠花', '小丽'],
        girls2: ['金莲', '马蓉'],
    }
    render() {
        const { money1, money2 } = this.state
        return (
            <div>
                <p>我是父组件</p>
                {/* 使用组件1 */}
                <Son1 money1={money1} girls1={this.state.girls1}></Son1>
                <p><button onClick={() => {
                    this.state.girls1.push('小三');
                    this.setState({
                        money1: money1 + 1000,
                        girls1: this.state.girls1
                    })


                }}>涨薪1000</button></p>
                {/* 使用组件2 */}
                <Son2 money2={money2} girls2={this.state.girls2}></Son2>
                <p><button onClick={() => {
                    this.state.girls2.push('小莲');
                    this.setState({
                        money2: money2 + 2000,
                        girls2: this.state.girls2
                    })
                    console.log('222')
                }}>涨薪2000</button></p>
            </div>
        )
    }
}
